import Cookies from 'js-cookie'

// 默认一小时
const defaultExpTime = 60 * 60 * 1000

export default class Secret {
  constructor(appkey) {
    if (!appkey) {
      throw new Error('请传入appkey')
    }
    this.SECRET = `secret_${appkey}`
  }

  // 获取上传图片的secret
  get() {
    return Cookies.get(this.SECRET)
  }

  // 设置上传图片的secret
  set(secret, ExpTime = defaultExpTime) {
    Cookies.set(this.SECRET, secret, ExpTime)
  }

  // 清除上传图片的secret
  remove() {
    return Cookies.remove(this.SECRET)
  }
}

